Socket
Socket
Sign inDemoInstall

@types/react-is

Package Overview
Dependencies
4
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/react-is

TypeScript definitions for react-is


Version published
Maintainers
1
Install size
1.37 MB
Created

Package description

What is @types/react-is?

The @types/react-is package provides TypeScript type definitions for the react-is library, which is a collection of utilities to determine the type of React elements. This is particularly useful for type-checking in TypeScript projects when working with dynamic React elements or when needing to assert the type of components or elements in the code.

What are @types/react-is's main functionalities?

Identifying React Elements

This feature allows you to check if a value is a React element. The code sample demonstrates how to use the `isElement` function to determine if a given value is a React element.

import * as ReactIs from 'react-is';

function isElement(element: any): boolean {
  return ReactIs.isElement(element);
}

Checking for Specific Element Types

These functions enable checking if a React element is a Fragment or a Portal, respectively. This is useful for conditional rendering or logic that depends on the type of component.

import * as ReactIs from 'react-is';

function isFragment(value: any): boolean {
  return ReactIs.isFragment(value);
}

function isPortal(value: any): boolean {
  return ReactIs.isPortal(value);
}

Identifying Context Consumers and Providers

This feature allows for the identification of Context Consumers and Providers, which can be useful in complex applications that make heavy use of React's Context API for managing state.

import * as ReactIs from 'react-is';

function isContextConsumer(value: any): boolean {
  return ReactIs.isContextConsumer(value);
}

function isContextProvider(value: any): boolean {
  return ReactIs.isContextProvider(value);
}

Other packages similar to @types/react-is

Readme

Source

Installation

npm install --save @types/react-is

Summary

This package contains type definitions for react-is (https://reactjs.org/).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-is/v16.

index.d.ts

export as namespace ReactIs;

import { LazyExoticComponent, MemoExoticComponent, ReactElement, ReactType } from "react";

export function typeOf(value: any): symbol | undefined;
export function isValidElementType(value: any): value is ReactType;
export function isAsyncMode(value: any): value is ReactElement;
export function isContextConsumer(value: any): value is ReactElement;
export function isContextProvider(value: any): value is ReactElement;
export function isElement(value: any): value is ReactElement;
export function isForwardRef(value: any): value is ReactElement;
export function isFragment(value: any): value is ReactElement;
export function isLazy(value: any): value is LazyExoticComponent<any>;
export function isMemo(value: any): value is MemoExoticComponent<any>;
export function isProfiler(value: any): value is ReactElement;
export function isPortal(value: any): value is ReactElement;
export function isStrictMode(value: any): value is ReactElement;
export function isSuspense(value: any): value is ReactElement;

export const AsyncMode: symbol;
export const ContextConsumer: symbol;
export const ContextProvider: symbol;
export const Element: symbol;
export const ForwardRef: symbol;
export const Fragment: symbol;
export const Lazy: symbol;
export const Memo: symbol;
export const Portal: symbol;
export const Profiler: symbol;
export const StrictMode: symbol;
export const Suspense: symbol;

Additional Details

  • Last updated: Tue, 07 Nov 2023 20:08:00 GMT
  • Dependencies: @types/react

Credits

These definitions were written by Avi Vahl, Christian Chown, and Sebastian Silbermann.

FAQs

Last updated on 07 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc